﻿Imports System.Data
Imports System.Data.Odbc
Imports WSEntidades
Imports Utilerias
Imports Npgsql
Imports MySql.Data.MySqlClient
Public Class ClientesFact
    Public Shared Function Build(ByVal dr As MySqlDataReader) As ClientesBE
        Dim tmpClientes As ClientesBE = New ClientesBE()
        Try
            With tmpClientes
                .IdCli = convertDTFromDb.convertInt32(dr.Item("IdCli"))
                .RfcCli = convertDTFromDb.ConvertString(dr.Item("RfcCli"))
                .RazonSocial = convertDTFromDb.ConvertString(dr.Item("RazonSocial"))
                .Nombre = convertDTFromDb.ConvertString(dr.Item("Nombre"))
                .Telefono = convertDTFromDb.ConvertString(dr.Item("Telefono"))
                .Fax = convertDTFromDb.ConvertString(dr.Item("Fax"))
                .CorreoElect = convertDTFromDb.ConvertString(dr.Item("CorreoElect"))
                .Observaciones = convertDTFromDb.ConvertString(dr.Item("Observaciones"))
                .IdExt = convertDTFromDb.ConvertString(dr.Item("IdExt"))
                .ContrIEPS = convertDTFromDb.ConvertBoolean(dr.Item("ContrIEPS"))
                .Calle = convertDTFromDb.ConvertString(dr.Item("Calle"))
                .NoExterior = convertDTFromDb.ConvertString(dr.Item("NoExterior"))
                .NoInterior = convertDTFromDb.ConvertString(dr.Item("NoInterior"))
                .Colonia = convertDTFromDb.ConvertString(dr.Item("Colonia"))
                .Localidad = convertDTFromDb.ConvertString(dr.Item("Localidad"))
                .Referencia = convertDTFromDb.ConvertString(dr.Item("Referencia"))
                .Municipio = convertDTFromDb.ConvertString(dr.Item("Municipio"))
                .Estado = convertDTFromDb.ConvertString(dr.Item("Estado"))
                .Pais = convertDTFromDb.ConvertString(dr.Item("Pais"))
                .CodigoPostal = convertDTFromDb.ConvertString(dr.Item("CodigoPostal"))
                Select Case convertDTFromDb.ConvertString(dr.Item("Status"))
                    Case "A"
                        .Status = ClientesBE.EstatusCliente.Activo
                    Case "I"
                        .Status = ClientesBE.EstatusCliente.Inactivo
                    Case Else
                        .Status = ClientesBE.EstatusCliente.Inactivo
                End Select
            End With
            Return tmpClientes
        Catch ex As Exception
            Throw
        Finally
            tmpClientes = Nothing
        End Try
    End Function
End Class
